package com.wenchao.jetpackdemo.viewpager2

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.wenchao.jetpackdemo.databinding.ActivityViewpager2Binding

class Viewpager2Activity : AppCompatActivity() {

    private lateinit var binding: ActivityViewpager2Binding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ActivityViewpager2Binding.inflate(layoutInflater)
        setContentView(binding.root)

        initViewpager()
    }

    private fun initViewpager() {
        val list = ArrayList<Int>()
        list.add(0)
        list.add(1)
        list.add(2)
        list.add(3)
        val myAdapter = MyAdapter()
        myAdapter.setList(list)
        binding.viewpager.adapter = myAdapter
    }

}